<script>
	import { useUserStore } from './store/user'
	import request from './utils/request'
	export default {
		onLaunch: function() {
			const userStore = useUserStore()
			wx.login({
				success: (res) => {
					if (res.code) {
						request.get("/user/login", {
							code: res.code
						}).then((response) => {
							const {
								openid,
								id,
								token
							} = response.data // 根据实际响应结构调整
							userStore.setOpenId(openid)
							userStore.setId(id)
							userStore.setToken(token)
						}).catch((error) => {
							console.error("登录失败:", error)
						})
					}
				}
			})
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import "static/style/index.css"
</style>